System.log("Testing maWriteStore")
--
size = 1000000
expectedValue = 7778
buffer = maBufferCreate(size)
maBufferSetInt(buffer, 8, expectedValue)
data = maCreatePlaceholder()
maCreateData(data, size)
maWriteData(data, buffer, 0, size)
store = maOpenStore("Store1", MAS_CREATE_IF_NECESSARY)
maWriteStore(store, data)
maCloseStore(store, 0)
maDestroyObject(data)
maBufferDelete(buffer)
--
data = maCreatePlaceholder()
store = maOpenStore("Store1", MAS_CREATE_IF_NECESSARY)
maReadStore(store, data)
maCloseStore(store, 0)
buffer = maBufferCreate(size)
maReadData(data, buffer, 0, size)
value = maBufferGetInt(buffer, 8)
maBufferDelete(buffer)
maDestroyObject(data)
--
if value == expectedValue then
  System.log("Test passed: Value is: " .. value)
else
  System.log("Test failed: Value is: " .. value .. " expected: " .. expectedValue)
end
